package com.timedomain.him.remake.models;

import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;

import android.annotation.SuppressLint;
import androidx.annotation.IntDef;

public class ChatMessage {

    public int id;
    public String content;
    public long date;
    @ChatMessageType
    public int type;
    public String audioFile;
    public String extra;

    public ChatMessage(int id,long date, String content,@ChatMessageType int type, String audioFile,String extra) {
        this.id = id;
        this.date = date;
        this.content = content;
        this.type = type;
        this.audioFile = audioFile;
        this.extra = extra;
    }

    public ChatMessage(long date,String content,@ChatMessageType int type, String audioFile,String extra) {
        this.id = -1;
        this.date = date;
        this.content = content;
        this.type = type;
        this.audioFile = audioFile;
        this.extra = extra;
    }

    @IntDef({TYPE_LOAD_INDICATOR,TYPE_MESSAGE,TYPE_PHONE_CALL,TYPE_SEND_MESSAGE,TYPE_SHARE_SONG,TYPE_TIME,TYPE_VOICE,TYPE_CLEAR_MORNING_TIME,TYPE_START_NIGHT_MODE})
    @Retention(RetentionPolicy.SOURCE)
    public @interface ChatMessageType{}

    public static final int TYPE_MESSAGE=0;
    public static final int TYPE_SEND_MESSAGE=1;
    public static final int TYPE_PHONE_CALL=2;
    public static final int TYPE_VOICE=3;
    public static final int TYPE_SHARE_SONG=4;
    public static final int TYPE_TIME=-2;
    public static final int TYPE_LOAD_INDICATOR=-114514; // This should never be stored in database.
    public static final int TYPE_START_NIGHT_MODE=-114515; // This should never be stored in database.
    public static final int TYPE_CLEAR_MORNING_TIME=-114516; // This should never be stored in database.


    @SuppressLint("SwitchIntDef")
    public String toGeneralString(){
        return switch (type){
            case TYPE_PHONE_CALL -> "[语音通话]";
            case TYPE_VOICE -> "语音";
            case TYPE_SHARE_SONG -> "[文件]";
            default -> content;
        };
    }
}
